package com.jzo2o.foundations.controller.consumer;

import com.jzo2o.foundations.model.dto.response.ServeAggregationSimpleResDTO;
import com.jzo2o.foundations.model.dto.response.ServeAggregationTypeSimpleResDTO;
import com.jzo2o.foundations.model.dto.response.ServeCategoryResDTO;
import com.jzo2o.foundations.model.dto.response.ServeSimpleResDTO;
import com.jzo2o.foundations.service.IHomeService;
import com.jzo2o.foundations.service.IServeAggregationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController("consumerServeController")
@RequestMapping("/customer/serve")
@Api(tags = "用户端 - 首页服务查询接口")
public class FirstPageServeController {


    @Resource
    private IHomeService homeService;

    @Autowired
    private IServeAggregationService serveAggregationService ;
    /***
     * 首页服务列表查询
     */
    @ApiOperation("首页服务列表")
    @ApiImplicitParams(
            @ApiImplicitParam(name = "regionId",value = "区域ID",required = true,dataTypeClass = Long.class)
    )
    @GetMapping("/firstPageServeList")
    public List<ServeCategoryResDTO> serveCategory(@RequestParam("regionId")Long regionId){

      return   homeService.queryServeIconCategoryByRegionIdCache(regionId);

    }
    @ApiOperation("服务类型列表")
    @ApiImplicitParams(
            @ApiImplicitParam(name = "regionId",value = "区域ID",required = true,dataTypeClass = Long.class)
    )
    @GetMapping("/serveTypeList")
    public List<ServeAggregationTypeSimpleResDTO>  serveCategory2(@RequestParam("regionId")Long regionId){
        return   homeService.queryServeIconCategoryByRegionIdCache2(regionId);
    }


    @ApiOperation("服务类型列表")
    @ApiImplicitParams(
            @ApiImplicitParam(name = "regionId",value = "区域ID",required = true,dataTypeClass = Long.class)
    )
    @GetMapping("/hotServeList")
    public List<ServeAggregationSimpleResDTO>  serveCategory3(@RequestParam("regionId")Long regionId){
        return   homeService.queryServeIconCategoryByRegionIdCache3(regionId);
    }

    @ApiOperation("根据id查询服务")
    @GetMapping("/{id}")
    public ServeAggregationSimpleResDTO  serveCategory4(@PathVariable("id") Long id){
        return   homeService.queryServeIconCategoryByRegionIdCache4(id);
    }

    @ApiOperation("服务搜索接口")
    @GetMapping("/search")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cityCode", value = "城市编码", required = true, dataTypeClass = String.class),
            @ApiImplicitParam(name = "serveTypeId", value = "服务类型id", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "keyword", value = "关键词", dataTypeClass = String.class)
    })
    public List<ServeSimpleResDTO> findServeList(@RequestParam("cityCode") String cityCode,
                                                 @RequestParam(value = "keyword",required = false)String keyword,
                                                 @RequestParam(value = "serveTypeId",required = false)Long serveTypeId){

        return serveAggregationService.findServeList(cityCode,keyword,serveTypeId);
    }



}
